/*******************************************************
 * registerEvent(Name, Place, Start-Month, Start-Date, *
 *               End-Date, Classification, Genre)      *
 *******************************************************/

registerEvent(grungefest2000, bradford, 9, 12, 14, adolescent, music).
registerEvent(moti-curry-house, bradford, -1, -1, -1, cheap, restaurant).
registerEvent(the-national-russian-jazz-ensemble, bradford, 1, 1, 1, family, music).
registerEvent(horrorfest-2000, leeds, 6, 4, 6, adult, cinema).
registerEvent(kiddyland-gokarting-championships, leeds, 10, 4, 4, family, sport).
registerEvent(dust, leeds, -1, -1, -1, adult, nightclub).
registerEvent(the-old-bar, leeds, -1, -1, -1, cheap, restaurant).
registerEvent(est-est-est, leeds, -1, -1, -1, expensive, restaurant).
registerEvent(corn-exchange-mall, leeds, -1, -1, -1, family, shopping).
registerEvent(manchester-city-zoo, manchester, -1, -1, -1, family, animal).
registerEvent(art-erotica-exhibition, manchester, 4, 10, 14, adult, art).
registerEvent(bbc-radio-5-live, manchester, 6, 7, 8, family, music).
registerEvent(steak-house, manchester, -1, -1, -1, medium, restaurant).
registerEvent(york-equine-festival, york, 5, 7, 14, family, sport).
registerEvent(york-science-museum, york, -1, -1, -1, family, science).
registerEvent(the-flying-horse-pub, york, -1, -1, -1, medium, restaurant).

foodAvailableAt(grungefest2000, cheap).
foodAvailableAt(corn-exchange-mall, medium).
foodAvailableAt(manchester-city-zoo, expensive).
foodAvailableAt(york-equine-festival, medium).
foodAvailableAt(york-science-museum, medium).

distance(york, leeds, 50).
distance(york, manchester, 100).
distance(leeds, manchester, 75).
distance(leeds, bradford, 25).
distance(manchester, bradford, 90).
distance(york, bradford, 60).

/*************************************
 * U T I L I T Y   F U N C T I O N S *
 *************************************/

near(X,Y)		   :- X = Y ;
			     (distance(X,Y,D), D =< 50);
			     (distance(Y,X,D), D =< 50).
			     
getDates(E,M,Ds,De)  :- registerEvent(E,_,M,Ds,De,_,_).
allYearEvent(E)      :- registerEvent(E,_,-1,-1,-1,_,_).
suitableForKids(E)   :- registerEvent(E,_,_,_,_,family,_).

/*************************************
 * E N D U S E R   F U N C T I O N S *
 *************************************/

getEvent(E,P,C,G)    :- registerEvent(E,P,_,_,_,C,G).
partyEvents(E,M,D,P) :- getEvent(E,Ep,family,G),
                        near(P,Ep),
                        G \= shopping,
                        getDates(E,Em,Ds,De),
                       (allYearEvent(E) ; (Ds =< D, De >= D, Em =:= M)).


nearEvents(E,P)      :- near(P,X), getEvent(E,X,_,_).
foodAvailable(E,T)   :- foodAvailableAt(E,T) ;
                       (getEvent(E,_,T,G), G = restaurant).


